import { Sequelize, DataTypes, Model } from "sequelize";

enum DEGREE { 
    SERIOURS_URGENT = 1,
    SERIOURS_NOT_URGENT = 2,
    NOT_SERIOURS_URGENT = 3,
    NOT_SERIOURS_NOT_URGENT = 4
}

enum STATUS { 
    ARCHIVE = -1,
    PROCESSING = 1
}

export = function (DB: Sequelize, Types: DataTypes) :any { 
    const attributes = {
        id: {
            type: Types.BIGINT,
            primaryKey: true,
            autoIncrement: true,
        },
        title: {
            type: Types.STRING(100),
            allowNull: false,
        },
        beginTime: {
            type: Types.DATE,
            allowNull: false,
        },
        endTime: {
            type: Types.DATE,
            allowNull: true,
        },
        category: {
            type: Types.BIGINT,
            allowNull: false,
        },
        uid: {
            type: Types.BIGINT,
            allowNull: false,
        },
        description: {
            type: Types.TEXT,
            allowNull: true,
        },
        degree: {
            type: Types.INTEGER,
            defaultValue: DEGREE.NOT_SERIOURS_URGENT,
        },
        status: {
            type: Types.INTEGER,
            defaultValue: STATUS.PROCESSING
        }
    };
    const options = {
        tableName: 'schedules',
        timestamps: true,
        underscore: true,
    };
    return DB.define('Schedule', attributes, options);
}